package com.fun.feifun.job.config;

import com.fun.feifun.job.handler.BackMsgOrderJobHandler;
import com.fun.feifun.job.handler.RefreshOrderJobHandler;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wukefei
 * @date $ $
 */


@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail refreshOrder() {
        return JobBuilder.newJob(RefreshOrderJobHandler.class)
                .withIdentity("refreshOrder")
                .storeDurably()
                .build();
    }
    @Bean
    public SimpleTrigger refreshOrderTrigger() {
        SimpleTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(refreshOrder())
                .withIdentity("refreshOrderTrigger")
                .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(60*5))
                .build();
        return trigger;
    }


    @Bean
    public JobDetail backUserOrderInfo() {
        return JobBuilder.newJob(BackMsgOrderJobHandler.class)
                .withIdentity("backUserOrder")
                .storeDurably()
                .build();
    }
    @Bean
    public SimpleTrigger backUserOrderInfoTrigger() {
        SimpleTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(backUserOrderInfo())
                .withIdentity("backUserOrderTrigger")
                .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(60))
                .build();
        return trigger;
    }
}
